package cn.handong.tool.algorithm.排序算法;

import org.junit.Test;

import java.util.Arrays;

public class SortAl {

    // 冒泡排序
    @Test
    public void sort(){
        int[] nums = {5,9,2,3,1};
        int temp;
        for (int i = 0; i < nums.length-1; i++) {
            for (int j = 0; j < nums.length-i-1; j++) {
                if (nums[j] > nums[j+1]){
                    temp = nums[j+1];
                    nums[j+1] = nums[j];
                    nums[j] = temp;
                }
            }
        }
        System.out.print(Arrays.toString(nums));
    }

}
